/*
 *  Preferenes.java 
 *    
 *    Copyright 2012 YAWP Project Team
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.googlecode.yawp.model;

import java.io.Serializable;

/**
 * Preferences Class represents all the users preference choices
 * @author Dan Spuches
 *
 */
public class Preferences implements Serializable {
	/**
	 * Enumeration of Users Units
	 * 
	 */
	public enum Units {US, METRIC};
	/**
	 * Enumeration for DataView values
	 *
	 */
	public enum DataView {DAILY, WEEKLY, MONTHLY};	
	private static final long serialVersionUID = 1L;	// serial version id
	private double height;				// height in specified units
	private double targetWeight;		// user's target weight in specified units 
	private boolean autoFill;			// if true, blank dates will be filled in with average data
	private Units units;				// User's units
	private DataView dataView;			// User's data view
	private String name;				// User's name

	/**
	 * Constructor that allows a user to pass a user name to it.  
	 * All other parameters will be defaults
	 * 
	 * @param name User's name
	 */
	public Preferences(String name) {
		this(name, Units.US, 0.0, 0.0, false, null, DataView.MONTHLY);
	}
	
	/**
	 * Custom constructor that allows for all parameters to be defined.
	 * 
	 * @param name User's name
	 * @param units Units that will be used for this user.  Must be one of "enum Units"
	 * @param targetWeight User's target weight in specified units
	 * @param height User's height in specified units
	 * @param autoFill Not currently used
	 * @param journalCategories Not currently used
	 * @param dataView Not currently used
	 */
	public Preferences(String name, Units units, double targetWeight,
			double height, boolean autoFill, Object journalCategories, DataView dataView) {
		this.name = name;
		this.units = units;
		this.targetWeight = targetWeight;
		this.height = height;
		this.autoFill = autoFill;
		this.dataView = dataView;
	}

	/**
	 * Standard getter method for user's height
	 * 
	 * @return User's height
	 */
	public double getHeight() {
		return height;
	}
	
	/**
	 * Standard setter method for user's height
	 * 
	 * @param height User's height
	 */
	public void setHeight(double height) {
		this.height = height;
	}
	
	/**
	 * Standard getter method for user's target weight
	 * 
	 * @return User's target weight
	 */
	public double getTargetWeight() {
		return targetWeight;
	}
	
	/**
	 * Standard setter method for user's target weight
	 * 
	 * @param targetWeight User's target weight
	 */
	public void setTargetWeight(double targetWeight) {
		this.targetWeight = targetWeight;
	}
	
	/**
	 * Standard getter method for auto-fill option.  When enabled, 
	 * auto-fill will fill in calculated data for any days that are 
	 * left blank by the user.
	 * 
	 * @return True if autoFill is enabled, false otherwise
	 */
	public boolean isAutoFill() {
		return autoFill;
	}
	
	/**
	 * Standard setter method for auto-fill option.  When enabled, 
	 * auto-fill will fill in calculated data for any days that are 
	 * left blank by the user.
	 * 
	 * @param autoFill True if autoFill is enabled, false otherwise
	 */
	public void setAutoFill(boolean autoFill) {
		this.autoFill = autoFill;
	}
	
	/**
	 * Standard getter method for user's units (true if metric, false if US)
	 * 
	 * @return True if units are metric; false otherwise
	 */
	public Units getUnits() {
		return units;
	}
	
	/**
	 * Standard setter method for units.  Should be one of the public
	 * static integers defined for units.
	 * 
	 * @param units Public static integer defined in Preferences class.
	 */
	public void setUnits(Units units) {
		this.units = units;
	}
	
	/**
	 * Standard setter method for the user's data view.
	 * 
	 * @return enum DataView representing the user's data view being used.
	 */
	public DataView getDataView() {
		return dataView;
	}
	
	/**
	 * Standard setter method for the user's data view
	 * 
	 * @param dataView enum DataView representing the user's data view being used.
	 */
	public void setDataView(DataView dataView) {
		this.dataView = dataView;
	}
	
	/**
	 * Standard getter method for the user's name
	 * 
	 * @return String representation of the user's name
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * Standard setter method for the user's name
	 * 
	 * @param name String representation of the user's name
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * Convert an Enum Units to a string representing the weight units
	 * 
	 * @param units The units to get weight units for
	 * @return A string representation of the weight units based on units specified
	 */
	public static String getWeightUnitName(Units units) {
		String retval = "";
		
		if (units == Units.US) { 
			retval = "LBS";
		} else if (units == Units.METRIC) {
			retval = "KGS";
		}
		
		return retval;
	}
	
	/**
	 * Convert an Enum Units to a string representing the height units
	 * 
	 * @param units The units to get height units for
	 * @return A string representation of the height units based on units specified
	 */
	public static String getHeightUnitName(Units units) {
		String retval = "";
		
		if (units == Units.US) { 
			retval = "Inches";
		} else if (units == Units.METRIC) {
			retval = "Centimeters";
		}
		
		return retval;
	}
	
}
